
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Length.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(Length)
{
        TEST(should be able to compare 1 feet with 12 inch)
        {
                Length feet(1, FEET);
                Length inch(12, INCH);

                ASSERT_EQ(true, feet==inch);
        }

        TEST(should be able to compare 1 yard with 3 feet)
        {
                Length yard(1, YARD);
                Length feet(3, FEET);

                ASSERT_EQ(true, feet==yard);
        }

        TEST(should be able to compare 1 mile with 1760 yard)
        {
                Length mile(1, MILE);
                Length yard(1760, YARD);

                ASSERT_EQ(true, mile==yard);
        }

        TEST(should be able to compare 1 feet with 12 inch)
        {
                Length feet(1, FEET);
                Length inch(12, INCH);
                Length feetAddCmp(2, FEET);

                ASSERT_EQ(true, feetAddCmp == feet + inch);
        }

        TEST(should be able to print 25 Inch as 0 Mile 0 Yard 2 Feet 1 Inch)
        {
                Length inch(25, INCH);
                Length mileAdd(0, MILE);
                Length yardAdd(0, YARD);
                Length feetAdd(2, FEET);
                Length inchAdd(1, INCH);

                ASSERT_EQ(true, inch == mileAdd + yardAdd + feetAdd + inchAdd);

                ostringstream lengthStream;
                string lengthString;
                string testString;

                inch << (lengthStream);
                lengthString = lengthStream.str();
                testString = "0 MILE 0 YARD 2 FEET 1 INCH";
                ASSERT_EQ(true, lengthString == testString);
        }

        TEST(should be able to print 25 Inch as 25 Inch and also 0 Mile 0 Yard 2 Feet 1 Inch)
        {
                Length inch(25, INCH);

                ostringstream lengthStreamFormat;
                string lengthStringFormat;
                string testString;

                inch.output(lengthStreamFormat, LengthFormatorInStdFormat);
                lengthStringFormat = lengthStreamFormat.str();
                testString = "0 MILE 0 YARD 2 FEET 1 INCH";
                ASSERT_EQ(true, lengthStringFormat == testString);

                ostringstream lengthStreamInBaseUnit;
                string lengthStringInBaseUnit;

                testString.clear();
                inch.output(lengthStreamInBaseUnit, LengthFormatorInBaseUnit);
                lengthStringInBaseUnit = lengthStreamInBaseUnit.str();
                testString = "25 INCH";
                ASSERT_EQ(true, lengthStringInBaseUnit == testString);
        }

};

